
<!-- middle content -->
<div id="middle-content" class="tmargin">
	<?php require_once 'filter.php';?>
	<div id="middle-center" class="left benner-list">
		<div class="list-banner">
			<?php 

			if (lang('list_view_banner') != '[list_view_banner]'){
				echo lang('list_view_banner',true);
			}
			?>
		</div>

		<div class="list-text">
			<?php 
			if (lang('list_view_text') != '[list_view_text]'){
				echo lang('list_view_text');
			}
			?>
		</div>
	</div>
	<div id="middle-center" class="left prod-list">
		<div id="settings-bar">
			<form id="get-products-filter" action=<?php echo site_url('product_list/get_list');?> method="get">
				<?php $search_price = isset($search['price_more']) ? $search['price_more'] : '';
					$search_price .= (isset($search['price_less'])) ? ',' . $search['price_less'] : '';
				?>
				<input type="hidden" name="current_url" id="current_url" value="<?php echo current_url();?>" />
				<input type="hidden" name="search-price" id="search-price" value="<?php echo $search_price;?>" />
				<input type="hidden" name="search-category" id="search-category" value="<?php echo isset($search['category']) ? $search['category'] : '';?>" />
				<input type="hidden" name="search-metal" id="search-metal" value="<?php echo isset($search['metal']) ? $search['metal'] : '';?>" />
				<input type="hidden" name="search-gem" id="search-gem" value="<?php echo isset($search['gem']) ? $search['gem'] : '';?>" />
				
				<div id="compare-btn">
					<div style="margin-top: 6px;">
					<?php echo lang('compare_button_text');?>
					</div>
				</div>
				
				<div style="line-height: 21px">
					<select name="limit" id="limit">
						<option value="8" <?php echo ((isset($search['per_page']) AND $search['per_page'] == 8) ? "selected='selected'" : "") ?>>8</option>
						<option value="12" <?php echo ((!isset($search['per_page']) OR $search['per_page'] == 12) ? "selected='selected'" : "") ?>>12</option>
						<option value="24" <?php echo ((isset($search['per_page']) AND $search['per_page'] == 24) ? "selected='selected'" : "") ?>>24</option>
						<option value="48" <?php echo ((isset($search['per_page']) AND $search['per_page'] == 48) ? "selected='selected'" : "") ?>>48</option>
					</select>
					<label for="limit"><?php echo lang('filter_limit_number');?></label>
				</div>
				
				<div style="line-height: 21px;">
					<select name="sidx" id="sidx" style="background-color: #000000">
						<option value="name" <?php echo ((!isset($search['order_by']) OR $search['order_by'] == 'name') ? "selected='selected'" : "") ?>><?php echo lang('order_by_name');?></option>
						<option value="price" <?php echo ((isset($search['order_by']) AND $search['order_by'] == 'price') ? "selected='selected'" : "") ?>><?php echo lang('order_by_price');?></option>
					</select>
					<label for="limit" style="margin-left:15px;"><?php echo lang('order_by');?></label>
				</div>
				
				<div style="line-height: 21px;">
					<select name="sord" id="sord">
						<option value="asc" <?php echo ((!isset($search['order_dir']) or $search['order_dir'] == 'asc') ? "selected='selected'" : "") ?>><?php echo lang('order_asc');?></option>
						<option value="desc" <?php echo ((isset($search['order_dir']) AND $search['order_dir'] == 'desc') ? "selected='selected'" : "") ?>><?php echo lang('order_desc');?></option>
					</select>
					<label for="limit" style="margin-left:15px;"><?php echo lang('order_direction');?></label>
				</div>
				<div class="clear"></div>
			</form>
		</div>
		<?php 
		if (!empty($products)){
			foreach($products as $product){
			?>
				<div class="product-list-item">
					<a href="<?php echo get_product_url($product->name,$product->id)?>">			
						<?php 
						if ($product->parent_id == 0){
							if (file_exists(SMALL_IMAGE_PATH . $product->url) AND strlen($product->url)){
								echo "<img src='" . SMALL_IMAGE_URL . $product->url . "' />";
							} else {
								echo "<img src='" . IMAGES_URL . "no_image_available.png' width='140px' />";
								
							}
						} 
						?>	
					</a>				
						<div class='product-info'>
							<a href="<?php echo get_product_url($product->name,$product->id)?>">
								<div class="name-container"><?php echo $product->name?></div>
							</a>
							
							<div class="desc">
								<?php echo lang('prod_price')?>: 
								<?php 
									echo get_prod_prices($product->id,$sel_currency,true);
									/*if ($product->special_price > 0){
										echo $exchange->transformPrice($product->special_price,$sel_currency) . ' - ';
									}
									echo $exchange->transformPrice($product->price,$sel_currency) . ' ' . $sel_currency;*/
								?>
							</div>
							
							<div class="checkbox-container">
								<input type="checkbox" name="compare" id="<?php echo $product->id;?>" value="<?php echo $product->id;?>" />
								<label for="compare"><?php echo lang('compare_text'); ?>
							</div>
							<?php 
								$user = $this->session->userdata('user');
								if ($user && $user['admin']){?>
									<a href="<?php echo site_url('admin/product_manager/edit/' .$product->id )?>"><?php echo lang('edit_product')?></a>
								<?php } 			
							?>
						</div>
				
				</div>
			<?php 
			}
		 }
		 ?>
	</div>
	
	<div id="paginator">
		<div style="float:left;margin-left:18px;">
			<div style="margin-top: 6px;">
				<?php echo lang('items') . ' ' . ($search['from']+1) . ' ' . lang('to') . ' ' . ($search['from']+$search['to']) . ' ' . lang('of') . ' ' . $search['total'] . ' ' . lang('total')?>
			</div>
		</div>
		<div class="compare-btn" style="float:right;margin-right:18px;">
			<div style="margin-top: 6px;">
				<?php echo lang('compare_button_text');?>
			</div>
		</div>
		<div style="margin-left:auto;margin-right:auto;width:340px;text-align:center">
			<div style="margin-top:6px;">
				<?php echo lang('page') . ': ' . $links;?>
			</div>
		</div>
		<div class="clear"></div>
	</div>
	<div class="clear"></div>
</div>